package com.jhhc.StormSurgeForecast.StormSurge.ServiceImpl;

import com.jhhc.StormSurgeForecast.StormSurge.Pojo.GZABO.OvertoppingInfo;
import com.jhhc.StormSurgeForecast.StormSurge.Service.CalculationService;
import com.jhhc.StormSurgeForecast.StormSurge.Uitl.FormulaUtil;
import com.jhhc.StormSurgeForecast.StormSurge.Uitl.VariableUtil;
import org.springframework.stereotype.Service;

/**
 * @author Admin
 */
@Service
public class CalculationServiceImpl implements CalculationService {


    /**
     * @param t 周期
     * @param z 潮位
     * @param hs 有效波高
     * @return OvertoppingInfo 人工岛越浪量与波浪爬高信息
     */
    @Override
    public OvertoppingInfo overtopping(double t,double z,double hs) {
        VariableUtil variableUtil = new VariableUtil();
        FormulaUtil formulaUtil = new FormulaUtil();
        // 波长L 护面糙渗系数Kdeerta 平台上水深dB  平台折减系数Kb  破波参数 ξ1% 超高Rc 坡肩折减系数Kc 坡肩宽度bc
        double bc = 5.7;
        double d = Double.parseDouble(variableUtil.calculationD(z));
        double h1 = hs * 1.5;
        String l = variableUtil.calculationL(d,t);
        String db = variableUtil.dB(z);
        String kb = variableUtil.Kb(hs,Double.parseDouble(db));
        String kexi = variableUtil.kexi1(h1,Double.parseDouble(l));
        String rc = variableUtil.Rc(z);
        String kc = variableUtil.Kc(bc);
        //波浪爬高 r  越浪量q
        String r = formulaUtil.RF(Double.parseDouble(kb),Double.parseDouble(kexi),h1);
        String q = formulaUtil.Q(hs,Double.parseDouble(kc),Double.parseDouble(kb),
                Double.parseDouble(kexi),Double.parseDouble(rc));
        OvertoppingInfo info = new OvertoppingInfo();
        info.setH1(String.valueOf(h1));
        info.setHs(String.valueOf(hs));
        info.setKb(kb);
        info.setKexi(kexi);
        info.setL(l);
        info.setType("扭工字块体（安放二层）");
        info.setZ(String.valueOf(z));
        info.setQ(q);
        info.setR(r);
        return info;
    }
}
